package com.zzx.boot.servlet.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzx.boot.entity.table.PostClass;
import com.zzx.boot.entity.table.TopicClass;
import com.zzx.boot.entity.vo.ClassVo;
import com.zzx.boot.mapper.TopicClassMapper;
import com.zzx.boot.servlet.TopicClassService;
import com.zzx.boot.utils.R;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author tan
 * @version 1.0
 * @date 2023/7/8 14:47
 */
@Service
public class TopicClassServiceImpl extends ServiceImpl<TopicClassMapper, TopicClass> implements TopicClassService {
    @Override
    public R getTopicClass() {
        LambdaQueryWrapper<TopicClass> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TopicClass::getStatus,1);
        wrapper.select(TopicClass::getId,TopicClass::getClassname);
        List<TopicClass> list = baseMapper.selectList(wrapper);
        List<ClassVo> vos = list.stream().map(item -> new ClassVo(item.getId().toString(), item.getClassname())).collect(Collectors.toList());
        return R.success(vos);
    }


}
